import request from "@/router/axios";

export function fetchList(query) {
  return request({
    url: "/admin/user/page",
    method: "get",
    params: query
  });
}

export function getSysUserToRevenue() {
  return request({
    url: "/admin/user/getSysUserToRevenue",
    method: "get"
  });
}
export function getSysUserByRoleCode() {
  return request({
    url: "/admin/user/getSysUserByRoleCode",
    method: "get"
  });
}

export function addObj(obj) {
  return request({
    url: "/admin/user",
    method: "post",
    data: obj
  });
}

export function getObj(id) {
  return request({
    url: "/admin/user/" + id,
    method: "get"
  });
}

export function delObj(id) {
  return request({
    url: "/admin/user/" + id,
    method: "delete"
  });
}

export function putObj(obj) {
  return request({
    url: "/admin/user",
    method: "put",
    data: obj
  });
}

export function getDetails(obj) {
  return request({
    url: "/admin/user/details/" + obj,
    method: "get"
  });
}

export function getByUserCode(obj) {
  return request({
    url: "/admin/user/details/usercode/" + obj,
    method: "get"
  });
}

export function checkPwd(userCode, password) {
  return request({
    url: `admin/user/check/${userCode}/${password}`,
    method: "get"
  });
}

export function checkPwdByAccount(username, password) {
  return request({
    url: `admin/user/check/account/${username}/${password}`,
    method: "get"
  });
}

export function saveBatch(body) {
  return request({
    url: "admin/user/import",
    headers: { "Content-Type": "multipart/form-data" },
    method: "post",
    data: body
  });
}

/**
 * 机电模板下载
 * @param {*} query
 * @returns
 */
export function templateJD(query) {
  return request({
    url: "admin/user/exportTamplateJD",
    method: 'get',
    responseType: 'blob',
    params: query
  })
}
/**
 * 机电人员导入
 * @param body
 */
 export function userImportJD(body) {
  return request({
    url: "admin/user/userImportJD",
    headers: { "Content-Type": "multipart/form-data" },
    method: "post",
    data: body
  });
}

/**
 * 客运模板下载
 * @param {*} query
 * @returns
 */
 export function templateKY(query) {
  return request({
    url: "admin/user/exportTamplateKY",
    method: 'get',
    responseType: 'blob',
    params: query
  })
}
/**
 * 客运人员导入
 * @param body
 */
 export function userImportKY(body) {
  return request({
    url: "admin/user/userImportKY",
    headers: { "Content-Type": "multipart/form-data" },
    method: "post",
    data: body
  });
}
//批量初始密码
export function updateBatch(body) {
  return request({
    url: "admin/user/updatePasswordBatch?ids="+body,
    method: "put"
  });
}
//修改用户状态
export function updateBatchLock(ids,flag){
  return request({
    url: "admin/user/updateBatchLock?ids=" + ids +"&flag="+flag,
    method: "put"
  });
}

export function getUserDeviceNoByCondition(lineCode, stationCode) {
  return request({
    url:
      "/support/swpmdeviceoperationcode/page?size=-1&lineCode=" +
      lineCode +
      "&stationCode=" +
      stationCode,
    method: "get"
  });
}

export function getUserDeviceNoByConditionLC(lineCode, stationCode) {
  return request({
    url:
      "/support/swpmdeviceoperationcode/page?size=-1&querySource=LC&lineCode=" +
      lineCode +
      "&stationCode=" +
      stationCode,
    method: "get"
  });
}
